<?php
session_start();
if (isset($_POST['openid']) && !empty($_POST['openid'])){
    include '../c/config.php';
    include 'thearray.php';
    $mysqli = new mysqli($dbhost, $dbuser, $dbpwd, $dbName);
    if (!$mysqli->set_charset("utf8")) {}
    $openid=addslashes(trim($_POST['openid']));
    $type=addslashes(trim($_POST['type']));
    $query=$mysqli->query("SELECT id,name,gao,weight,zubie FROM uinfo where openid='".$openid."' limit 0,1 ");
    $user=array();
    $zuList=['U6','U8','U10','U12','U14'];
    if($query->num_rows>0){
        $getUser=$query->fetch_assoc();
        $user=$getUser;
        $user['zubie']=$zuList[$getUser['zubie']]; 
    }
     
    $getUser=NULL;
    $query=$mysqli->query("SELECT qiuid,weizhi,qiuhao FROM joinqiu where openid='".$openid."' limit 0,1 ");
    if($query->num_rows>0){
        $getJoin=$query->fetch_assoc();
        $queryQiu=$mysqli->query("SELECT name FROM qdui where id='".$getJoin['qiuid']."' limit 0,1 ");
        $getQiu=$queryQiu->fetch_assoc();
        $user['qiudui']=$getQiu['name'];
        $user['qiuhao']=$getJoin['qiuhao'];
        $user['weizhi']=$weizhiList[$getJoin['weizhi']];
        
    }
    
    $sai=array();
    if ('ke' == $type){
        $baoId=array();
        $query=$mysqli->query("SELECT sid FROM baoming where openid='".$openid."'  ");
        while ($list=$query->fetch_assoc()){
            $baoId[]=$list['sid'];
        }
        $query=$mysqli->query("SELECT id,name FROM saisi where isopen=1  ");
        while ($list=$query->fetch_assoc()){
            $hasbao='';
            if (in_array($list['id'], $baoId)){
                $hasbao='y';
            }
            $sai[]=array('id'=>$list['id'],'name'=>$list['name'],'hsb'=>$hasbao);
        }
    }
    
    
    $mysqli->close();
    
    echo json_encode(array('u'=>$user,'s'=>$sai));
}

